#ifndef __CONFIG_H_
#define __CONFIG_H_
#include <stdint.h>
#include <map>
#include <string>
#include "filelinkblock.h"

using namespace std;

class Config
{
	private:
		static const char* const m_StrLogLevel;
		static const char* const m_StrLogSize;
		static const char* const m_StrLogName;

		static const char* const m_StrQuerySendTimeOut;
		static const char* const m_StrQueryRecvTimeOut;
		static const char* const m_StrCiPort;
		static const char* const m_StrServiceThreadNum;
		static const char* const m_StrThreadBufferSize;
		static const char* const m_StrEpollSize;

		// log config
		uint32_t  m_log_level; // DEBUG, ROUTN, ALARM, FATAL
		uint32_t  m_log_size;  // max log size
		const char* m_log_name; // logname

        // ci server config
        uint32_t m_pollsize; // socket pool size
		uint32_t m_ci_port;
		uint32_t m_thread_buffer_size;
		uint32_t m_service_thread_num;
		uint32_t m_rtimeout_ms;
		uint32_t m_wtimeout_ms;

        // queue map
        map<string, FileLinkBlock*> m_queue_map;

		Config();
		Config(const Config&);
	public:
		Config(const char* configpath);
		~Config(){}

		uint32_t RTimeMS()  const { return m_rtimeout_ms; }
		uint32_t WTimeMS()  const { return m_wtimeout_ms; }
		uint16_t QueryPort() const { return m_ci_port; }
		uint32_t PollSize() const { return m_pollsize; }
		uint32_t ServiceThreadNum() const { return m_service_thread_num; }
		uint32_t ThreadBufferSize() const { return m_thread_buffer_size; }

        FileLinkBlock* GetQueue(const char* qname)
        {
            if (m_queue_map.end() == m_queue_map.find(string(qname)))
            {
                return NULL;
            }
            else
            {
                return m_queue_map[string(qname)];
            }
        }
};

#endif
